package com.zan.pattern.iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author Zan
 * @Create 2024/4/27 16:41
 * @Description : 具体聚合角色类
 * @ClassName: StudentAggregateImpl
 */
public class StudentAggregateImpl implements StudentAggregate {

    private List<Student> list = new ArrayList<>();

    @Override
    public void addStudent(Student student) {
        this.list.add(student);
    }

    @Override
    public void removeStudent(Student student) {
        this.list.remove(student);
    }

    // 获取迭代器对象
    @Override
    public StudentIterator getStudentIterator() {
        return new StudentIteratorImpl(this.list);
    }
}
